﻿// Author: AustralTek 
// Create date: 2010/05/04
// http://www.australtek.com
// Copyright: 2009 - 2010

(function () {
    function _FX() {
        // ---------------------------- ShadowClass ----------------------------------- //
        function _ShadowClass(object, options) {
            try {
                //Private Members
                var privateShadowParameters = null;

                function _instantiating() {
                    var duration = 250; //defaultValue
                    var color = '#000000';
                    var border = 5;

                    var el = privateShadowParameters.el;
                    var options = privateShadowParameters.Options;

                    if ((options) && (options != undefined)) {
                        if (options.duration != undefined) duration = options.duration;
                        if (options.RGBColor != undefined) color = options.RGBColor;
                        if (options.border != undefined) border = options.border;
                    }
                    if (el) {
                        if (el.shadow == undefined) {
                            el.shadow = {};
                            el.shadow.duration = duration;
                            el.shadow.isAvailable = true;
                            el.shadow.wasChanged = false;
                            el.shadow.tt = el.shadow.duration / privateShadowParameters.tickTimes;

                            var currentStyle = (el.currentStyle || el.style);
                            el.shadow.position = currentStyle.position;
                            if (currentStyle.height.indexOf('px') > -1) el.shadow.hUnit = 'px'
                            else if (currentStyle.height.indexOf('%') > -1) el.shadow.hUnit = '%'
                            else { el.shadow.hUnit = 'px'; }
                            if (currentStyle.width.indexOf('px') > -1) el.shadow.wUnit = 'px'
                            else if (currentStyle.width.indexOf('%') > -1) el.shadow.wUnit = '%'
                            else { el.shadow.wUnit = 'px'; }
                            var sd = document.createElement('div');
                            var elh = parseFloat(currentStyle.height.replace(el.shadow.hUnit, ''));
                            var elw = parseFloat(currentStyle.width.replace(el.shadow.wUnit, ''));
                            if ((elh.toString() == 'NaN') || (elw.toString() == 'NaN')) {
                                privateShadowParameters.isCreated = false;
                                return false;
                            }
                            sd.style.height = (elh + border) + el.shadow.hUnit;
                            sd.style.width = (elw + border) + el.shadow.wUnit;

                            sd.style.marginLeft = currentStyle.marginLeft; el.style.marginLeft = '0px';
                            sd.style.marginTop = currentStyle.marginTop; el.style.marginTop = '0px';
                            sd.style.marginRight = currentStyle.marginRight; el.style.marginRight = '0px';
                            sd.style.marginBottom = currentStyle.marginBottom; el.style.marginBottom = '0px';

                            sd.style.left = currentStyle.left; sd.style.top = currentStyle.top; sd.style.right = currentStyle.right;
                            sd.style.bottom = currentStyle.bottom; sd.style.position = el.shadow.position;

                            el.style.left = '0px'; el.style.right = '0px'; el.style.top = '0px'; el.style.bottom = '0px'; el.style.margin = '0px';

                            el.shadow.hCurrent = elh;
                            el.shadow.wCurrent = elw;
                            el.shadow.border = border;
                            el.shadow.color = color;
                            privateShadowParameters.tickTimes = duration / border;

                            var style;

                            //bottom
                            el.shadow.bShadow = document.createElement('div');
                            style = el.shadow.bShadow.style;
                            style.position = 'absolute';
                            //style.float='right';               

                            var styleTop = 0;
                            if (currentStyle.borderTopWidth != '') styleTop = parseInt(currentStyle.borderTopWidth.replace('px', ''));
                            if (currentStyle.borderBottomWidth != '') styleTop += parseInt(currentStyle.borderBottomWidth.replace('px', ''));
                            if (styleTop.toString() == 'NaN') styleTop = 0;

                            style.bottom = styleTop * -1 + el.shadow.hUnit;
                            //style.top = '0px';//(styleTop/2) + el.shadow.hUnit;                
                            style.height = border + el.shadow.hUnit;
                            style.width = elw + el.shadow.wUnit; ;
                            style.background = 'transparent';

                            //right
                            el.shadow.rShadow = document.createElement('div');
                            style = el.shadow.rShadow.style;
                            style.position = 'absolute';

                            var styleLeft = 0;
                            if (currentStyle.borderLeftWidth != '') styleLeft = parseInt(currentStyle.borderLeftWidth.replace('px', ''));
                            if (currentStyle.borderRightWidth != '') styleLeft += parseInt(currentStyle.borderRightWidth.replace('px', ''));

                            if (styleLeft.toString() == 'NaN') styleLeft = 0;

                            style.top = '0px'//;((elh + styleTop + border)*-1) + el.shadow.hUnit;
                            style.left = (elw + styleLeft) + el.shadow.wUnit;
                            style.width = border + el.shadow.wUnit;
                            style.height = elh + el.shadow.hUnit;
                            style.background = 'transparent';

                            var pE = el.parentNode;
                            if (pE) {
                                pE.removeChild(el);
                                pE.appendChild(sd);
                                sd.appendChild(el);
                                sd.appendChild(el.shadow.bShadow);
                                sd.appendChild(el.shadow.rShadow);
                            }
                            el.shadow.bTop = styleTop;
                            el.shadow.bLeft = styleLeft;

                            var mt = 0;
                            var ml = 0;
                            var maxFo = 0.6;
                            var minFo = 0.1;
                            var fo = (maxFo - minFo) / border;
                            var currentFo = maxFo;
                            var style;
                            for (var ib = 0; ib < el.shadow.border; ib++) {
                                var sb = document.createElement('div');
                                var sr = document.createElement('div');
                                style = sb.style;

                                style.height = '1px';
                                style.width = styleLeft + 1 + el.shadow.wCurrent + el.shadow.wUnit;
                                style.background = el.shadow.color;
                                style.position = 'absolute';
                                style.left = ml + el.shadow.wUnit;
                                style.top = ml + el.shadow.wUnit;
                                style.opacity = currentFo;
                                style.filter = 'alpha(opacity=' + currentFo * 100 + ')';
                                style.display = 'none';

                                style = sr.style;
                                style.width = '1px';
                                style.height = styleTop + el.shadow.hCurrent + el.shadow.hUnit;
                                style.background = el.shadow.color;
                                style.position = 'absolute';
                                style.top = mt + el.shadow.hUnit;
                                style.left = mt + el.shadow.hUnit;
                                style.opacity = currentFo;
                                style.filter = 'alpha(opacity=' + currentFo * 100 + ')';
                                style.display = 'none';

                                currentFo -= fo;

                                el.shadow.bShadow.appendChild(sb);
                                el.shadow.rShadow.appendChild(sr);

                                mt++;
                                ml++;
                            }

                            privateShadowParameters.isCreated = true;
                            return true;
                        }
                    }
                    else return false;
                }

                function _initialize(myDiv, options) {
                    try {
                        privateShadowParameters = {};
                        privateShadowParameters.el = myDiv;
                        privateShadowParameters.Options = options;
                        privateShadowParameters.Events = (options.Events) ? options.Events : {};
                        privateShadowParameters.isCreated = false;
                        //this.parameters.fx = fx;
                        privateShadowParameters.tickTimes = 10;
                        _instantiating();
                        return this;
                    } catch (Error) { privateShadowParameters.Events.onError(Error); }
                }

                function _toogle() {
                    try {
                        if (!privateShadowParameters.isCreated) {
                            if (!this._instantiating(privateShadowParameters.el, privateShadowParameters.Options))
                                return;
                        }
                        if ((privateShadowParameters.el) && (privateShadowParameters.el.shadow)) {
                            var el = privateShadowParameters.el;
                            if ((!el.shadow.wasChanged) && (el.shadow.isAvailable)) _shadowIn();
                            else _shadowOut();
                        }
                    } catch (Error) { privateShadowParameters.Events.onFailure(Error); }
                }

                function _shadowIn() {
                    try {
                        if (!privateShadowParameters.isCreated) {
                            if (!this.instantiating(privateShadowParameters.el, privateShadowParameters.Options))
                                return;
                        }
                        var el = privateShadowParameters.el;
                        if ((!el.shadow.wasChanged) && (el.shadow.isAvailable)) {
                            el.shadow.isAvailable = false;
                            el.shadow.wasChanged = true;

                            var iChild = 0;
                            if (privateShadowParameters.Events.onStart)
                                privateShadowParameters.Events.onStart(this);
                            for (var tm = 0; tm < (el.shadow.duration); tm += privateShadowParameters.tickTimes) {
                                var child;

                                child = el.shadow.bShadow.childNodes[iChild];
                                if (child) child.style.display = '';
                                child = el.shadow.rShadow.childNodes[iChild];
                                if (child) child.style.display = '';
                                iChild++;
                            }
                            setTimeout(function () {
                                el.shadow.isAvailable = true; if (privateShadowParameters.Events.onStop)
                                    privateShadowParameters.Events.onStop(this); if (privateShadowParameters.Events.onComplete)
                                    privateShadowParameters.Events.onComplete(this);
                            }, el.shadow.duration);
                        }
                    } catch (Error) { privateShadowParameters.Events.onFailure(Error); }
                }

                function _shadowOut() {
                    try {
                        if (!privateShadowParameters.isCreated) {
                            if (!this._instantiating(privateShadowParameters.el, privateShadowParameters.Options))
                                return;
                        }
                        var el = privateShadowParameters.el;
                        if ((el.shadow.wasChanged) && (el.shadow.isAvailable)) {
                            el.shadow.isAvailable = false;
                            el.shadow.wasChanged = false;

                            var iChild = el.shadow.border - 1;
                            if (privateShadowParameters.Events.onStart)
                                privateShadowParameters.Events.onStart(this);

                            for (var tm = 0; tm < (el.shadow.duration); tm += privateShadowParameters.tickTimes) {
                                var child;
                                child = el.shadow.bShadow.childNodes[iChild];
                                if (child) child.style.display = 'none';
                                //setTimeout(function () { this.style.display = 'none'; } .bind(child), tm);
                                child = el.shadow.rShadow.childNodes[iChild];
                                if (child) child.style.display = 'none';
                                //setTimeout(function () { this.style.display = 'none'; } .bind(child), tm);
                                iChild--;
                            }
                            setTimeout(function () {
                                el.shadow.isAvailable = true; if (privateShadowParameters.Events.onStop)
                                    privateShadowParameters.Events.onStop(this); if (privateShadowParameters.Events.onComplete)
                                    privateShadowParameters.Events.onComplete(this);
                            }, el.shadow.duration);
                        }
                    } catch (Error) { privateShadowParameters.Events.onFailure(Error); }
                }

                _initialize(object, options);

                //Public Members

                this.Toogle = function () {
                    _toogle();
                };
                this.ShadowIn = function () {
                    _shadowIn();
                };
                this.ShadowOut = function () {
                    _shadowOut();
                };

                return this;
            } catch (Error) { privateParameters.Events.onError(Error); }
        }
        // ---------------------------------------------------------------------------- //       

        // ---------------------------- DragClass ------------------------------------- //
        function _DragClass(object, options) {
            try {
                //Private Members
                var privateDragParameters = null;
                function _instantiating() {
                    try {
                        var duration = 150;
                        var vRestrict = true;
                        var hRestrict = true;
                        var left = null;
                        var top = null;
                        var right = null;
                        var bottom = null;
                        var el = privateDragParameters.el;
                        var options = privateDragParameters.Options;

                        if ((options) && (options != undefined)) {
                            if (options.duration != undefined) duration = options.duration;
                            if (options.allowVertical != undefined) vRestrict = options.allowVertical;
                            if (options.allowHorizontal != undefined) hRestrict = options.allowHorizontal;
                            if (options.left != undefined) left = options.left;
                            if (options.top != undefined) top = options.top;
                            if (options.right != undefined) right = options.right;
                            if (options.bottom != undefined) bottom = options.bottom;
                        }
                        if (el) {
                            if (el.drag == undefined) {
                                el.drag = {};
                                el.drag.duration = duration;
                                el.drag.isAvailable = true;
                                el.drag.wasChanged = false;
                                privateDragParameters.mouseOffset = null;
                                privateDragParameters.isAvailable = false;
                                privateDragParameters.position = {};
                                el.drag.position = 'absolute';

                                if (left) {
                                    if (left.indexOf('%') > -1) { privateDragParameters.position.hUnit = '%'; privateDragParameters.position.left = parseFloat(left.replace('%', '')); }
                                    else if (left.indexOf('px') > -1) { privateDragParameters.position.hUnit = 'px'; privateDragParameters.position.left = parseFloat(left.replace('px', '')); }
                                    else { privateDragParameters.position.left = parseFloat(left); el.drag.hUnit = 'px'; }
                                }
                                else { privateDragParameters.position.left = null; privateDragParameters.position.hUnit = 'px'; }
                                if (top) {
                                    if (top.indexOf('%') > -1) { privateDragParameters.position.vUnit = '%'; privateDragParameters.position.top = parseFloat(top.replace('%', '')); }
                                    else if (top.indexOf('px') > -1) { privateDragParameters.position.vUnit = 'px'; privateDragParameters.position.top = parseFloat(top.replace('px', '')); }
                                    else { privateDragParameters.position.top = parseFloat(top); privateDragParameters.position.vUnit = 'px'; }
                                }
                                else { privateDragParameters.position.top = null; privateDragParameters.position.vUnit = 'px'; }
                                if (right) {
                                    if (right.indexOf('%') > -1) { privateDragParameters.position.hUnit = '%'; privateDragParameters.position.right = parseFloat(right.replace('%', '')); }
                                    else if (right.indexOf('px') > -1) { privateDragParameters.position.hUnit = 'px'; privateDragParameters.position.right = parseFloat(right.replace('px', '')); }
                                    else { privateDragParameters.position.right = parseFloat(right); privateDragParameters.position.hUnit = 'px'; }
                                }
                                else { privateDragParameters.position.right = null; privateDragParameters.position.hUnit = 'px'; }
                                if (bottom) {
                                    if (bottom.indexOf('%') > -1) { privateDragParameters.position.vUnit = '%'; privateDragParameters.position.bottom = parseFloat(bottom.replace('%', '')); }
                                    else if (bottom.indexOf('px') > -1) { privateDragParameters.position.vUnit = 'px'; privateDragParameters.position.bottom = parseFloat(bottom.replace('px', '')); }
                                    else { privateDragParameters.position.bottom = parseFloat(bottom); privateDragParameters.position.vUnit = 'px'; }
                                }
                                else { privateDragParameters.position.bottom = null; privateDragParameters.position.vUnit = 'px'; }

                                privateDragParameters.position.hRestrict = false;
                                privateDragParameters.position.vRestrict = false;
                                if ((left) && (right)) { privateDragParameters.position.hRestrict = true }
                                else if ((top) && (bottom)) { privateDragParameters.position.vRestrict = true; }
                                _makeDraggable(true);
                                el.drag.isCreated = true;
                                return true;
                            } //else
                            return false;
                        }
                        return false;
                    } catch (Error) { privateDragParameters.Events.onError(Error); }
                };

                function _initialize(myDiv, options) {
                    try {
                        privateDragParameters = {};
                        privateDragParameters.el = myDiv;
                        privateDragParameters.Options = options;
                        privateDragParameters.Events = (options.events) ? options.events : {};
                        privateDragParameters.isCreated = false;
                        //this.parameters.fx = fx;
                        privateDragParameters.tickTimes = 10;
                        _instantiating();
                        return this;
                    } catch (Error) { privateDragParameters.Events.onError(Error); }
                };

                function _makeDraggable(st) {
                    try {
                        if (!privateDragParameters.el) return;
                        if (st) {
                            privateDragParameters.el.onmousedown = function () { _dragMousedown.call(this); };
                            document.onmouseup = function () { _dragMouseup.call(this); };
                            privateDragParameters.el.onmouseup = function () { _dragMouseup.call(this); };
                            switch (true) {
                                case ((!privateDragParameters.position.hRestrict) && (!privateDragParameters.position.vRestrict)):
                                    document.onmousemove = function () { _dragUnrestrictedStart.call(this); }; break;
                                case ((!privateDragParameters.position.hRestrict) || (!privateDragParameters.position.vRestrict)):
                                    document.onmousemove = function () { _dragRestrictedStart.call(this); }; break;
                            }
                        } else {
                            privateDragParameters.el.onmousedown = function () { };
                            document.onmouseup = function () { };
                            privateDragParameters.el.onmouseup = function () { };
                            switch (true) {
                                case ((!privateDragParameters.position.hRestrict) && (!privateDragParameters.position.vRestrict)):
                                    document.onmousemove = function () { }; break;
                                case ((!privateDragParameters.position.hRestrict) || (!privateDragParameters.position.vRestrict)):
                                    document.onmousemove = function () { }; break;
                            }
                        }
                    } catch (Error) { privateDragParameters.Events.onError(Error); }
                };

                function _dragMousedown() {
                    privateDragParameters.isAvailable = true;
                    privateDragParameters.mouseOffset = _getMouseOffset(privateDragParameters.el, this);
                    return false;
                };

                function _dragMousedown() {
                    var e = e || window.event;
                    privateDragParameters.isAvailable = true;
                    privateDragParameters.mouseOffset = _getMouseOffset(privateDragParameters.el, e);
                    return false;
                };

                function _dragMouseup() {
                    privateDragParameters.isAvailable = false;
                };

                function _dragUnrestrictedStart() {
                    if ((privateDragParameters.isAvailable) && (privateDragParameters.mouseOffset)) {  //if(this.parameters.dragObject){  
                        var e = e || window.event;
                        var mousePos = _mouseCoords(e);
                        //if (privateDragParameters.position.vRestrict)
                        privateDragParameters.el.style.top = mousePos.y - privateDragParameters.mouseOffset.y;
                        //if (privateDragParameters.position.hRestrict)
                        privateDragParameters.el.style.left = mousePos.x - privateDragParameters.mouseOffset.x;
                        return false;
                    }
                };

                function _dragRestrictedStart() {
                    if ((privateDragParameters.isAvailable) && (privateDragParameters.mouseOffset)) {  //if(this.parameters.dragObject){  
                        var e = e || window.event;
                        var mousePos = _mouseCoords(e);
                        var left = mousePos.x - privateDragParameters.mouseOffset.x;
                        var top = mousePos.y - privateDragParameters.mouseOffset.y;
                        if ((top > privateDragParameters.position.top) && (top < privateDragParameters.position.bottom) && (privateDragParameters.position.vRestrict))
                            privateDragParameters.el.style.top = top;
                        if ((left > privateDragParameters.position.left) && (left < privateDragParameters.position.right) && (privateDragParameters.position.hRestrict))
                            privateDragParameters.el.style.left = left;
                        return false;
                    }
                };
                function _getMouseOffset(target, e) {
                    var docPos = _getPosition(target);
                    var mousePos = _mouseCoords(e);
                    return { x: mousePos.x - docPos.x, y: mousePos.y - docPos.y };
                };
                function _getPosition(target) {
                    var left = 0;
                    var top = 0;
                    while (target.offsetParent) {
                        left += target.offsetLeft;
                        top += target.offsetTop;
                        target = target.offsetParent;
                    }

                    left += target.offsetLeft;
                    top += target.offsetTop;

                    return { x: left, y: top };
                };
                function _mouseCoords(e) {
                    if (e.pageX || e.pageY) {
                        return { x: e.pageX, y: e.pageY };
                    }
                    return { x: e.clientX + document.body.scrollLeft - document.body.clientLeft, y: e.clientY + document.body.scrollTop - document.body.clientTop };
                };
                _initialize(object, options);

                //Public Members
                this.release = function () {
                    _makeDraggable(false);
                };
                this.Active = function () {
                    _makeDraggable(true);
                };
            } catch (Error) { privateDragParameters.Events.onError(Error); }
        }
        // ---------------------------------------------------------------------------- //

        // ---------------------------- TransformClass -------------------------------- //
        function _TransformClass(object, options) {
            try {
                var privateTransformParameters = null;
                var elem = null;
                function _instantiating() {
                    try {
                        var duration = 150; //defaultValue
                        var H1 = -1; var H2 = -1;
                        var W1 = -1; var W2 = -1;
                        var aj;
                        var el = privateTransformParameters.el;
                        var options = privateTransformParameters.Options;

                        if ((options) && (options != undefined)) {
                            if (options.duration != undefined) duration = options.duration;
                            if (options.toWidth != undefined) W2 = options.toWidth;
                            if (options.fromWidth != undefined) W1 = options.fromWidth;
                            if (options.toHeight != undefined) H2 = options.toHeight;
                            if (options.fromHeight != undefined) H1 = options.fromHeight;
                        }
                        if (el) {
                            if (el.transform == undefined) {
                                el.transform = {};
                                el.transform.wasChanged = false;
                                el.transform.isAvailable = true;
                                el.transform.duration = duration;
                                if ((W1 == -1) && (W2 == -1)) { W1 = el.clientWidth; W2 = el.clientWidth; }
                                else {
                                    if (W1 == -1) W1 = el.clientWidth;
                                    if (W2 == -1) W2 = 0;
                                }
                                if (H2 == -1) H2 = 0;
                                if (H1 == -1) H1 = el.clientHeight;
                                el.transform.hFrom = H1;
                                el.transform.wFrom = W1;
                                el.transform.hTo = H2;
                                el.transform.wTo = W2;
                                el.transform.tt = el.transform.duration / privateTransformParameters.tickTimes;

                                if (el.style.height.indexOf('px') > -1) el.transform.hUnit = 'px'
                                else if (el.style.height.indexOf('%') > -1) el.transform.hUnit = '%'
                                else { el.transform.hUnit = 'px'; }
                                if (el.style.width.indexOf('px') > -1) el.transform.wUnit = 'px'
                                else if (el.style.width.indexOf('%') > -1) el.transform.wUnit = '%'
                                else { el.transform.wUnit = 'px'; }

                                privateTransformParameters.isCreated = true;
                            }
                            else if (privateTransformParameters.isCreated) {
                                el.transform.duration = duration;
                                if ((W1 == -1) && (W2 == -1)) { W1 = el.clientWidth; W2 = el.clientWidth; }
                                else {
                                    if (W1 == -1) W1 = 0;
                                    if (W2 == -1) W2 = 0;
                                }
                                if (H2 == -1) H2 = 0;
                                if (H1 == -1) H1 = el.clientHeight;
                                el.transform.hFrom = H1;
                                el.transform.wFrom = W1;
                                el.transform.hTo = H2;
                                el.transform.wTo = W2;
                                el.transform.tt = el.transform.duration / privateTransformParameters.tickTimes;

                                if (el.style.height.indexOf('px') > -1) el.transform.hUnit = 'px'
                                else if (el.style.height.indexOf('%') > -1) el.transform.hUnit = '%'
                                else { el.transform.hUnit = 'px'; }
                                if (el.style.width.indexOf('px') > -1) el.transform.wUnit = 'px'
                                else if (el.style.width.indexOf('%') > -1) el.transform.wUnit = '%'
                                else { el.transform.wUnit = 'px'; }
                            }
                        }
                        else return;
                    } catch (Error) { privateTransformParameters.Events.onError(Error); }
                };
                function _initialize(myDiv, options) {
                    try {
                        privateTransformParameters = {}
                        privateTransformParameters.el = myDiv;
                        privateTransformParameters.Options = options;
                        privateTransformParameters.isCreated = false;
                        //privateDragParameters.fx = fx;
                        privateTransformParameters.Events = (options.events) ? options.events : {};
                        privateTransformParameters.tickTimes = 10;
                        _instantiating();
                        return this;
                    } catch (Error) { privateTransformParameters.Events.onError(Error); }
                };
                function _newTransform(options) {
                    var el = privateTransformParameters.el;
                    _instantiating(el, options);
                    _transform();
                };
                function _transform() {
                    try {
                        if (!privateTransformParameters.isCreated) {
                            privateTransformParameters.isCreated = true;
                            _instantiating(privateTransformParameters.el, privateTransformParameters.Options);
                        }
                        var el = privateTransformParameters.el;
                        el.transform.isAvailable = false;
                        el.transform.hCurrent = el.transform.hFrom;
                        el.transform.wCurrent = el.transform.wFrom;
                        el.transform.sw = (el.transform.wTo - el.transform.wFrom) / el.transform.tt;
                        el.transform.sh = (el.transform.hTo - el.transform.hFrom) / el.transform.tt;
                        if (privateTransformParameters.Events.onStart) privateTransformParameters.Events.onStart(this);
                        for (var tm = 0; tm < (el.transform.duration); tm += privateTransformParameters.tickTimes) {
                            setTimeout(_transformthis.apply(el), tm);
                        }
                        setTimeout(function () {
                            el.transform.isAvailable = true; if (privateTransformParameters.Events.onStop) privateTransformParameters.Events.onStop(this);
                            if (privateTransformParameters.Events.onComplete) privateTransformParameters.Events.onComplete(this);
                        }, el.transform.duration);
                    } catch (Error) { privateTransformParameters.Events.onError(Error); }
                };
                function _transformthis() {
                    try {
                        if (elem) {
                            elem.transform.hCurrent += elem.transform.sh;
                            elem.transform.wCurrent += elem.transform.sw;
                            elem.style.width = elem.transform.wCurrent + elem.transform.wUnit;
                            elem.style.height = elem.transform.hCurrent + elem.transform.hUnit;
                        }
                    } catch (Error) { privateTransformParameters.Events.onError(Error); }
                };
                function _toogle() {
                    try {
                        if (!privateTransformParameters.isCreated) {
                            privateTransformParameters.isCreated = true;
                            this.instantiating(privateTransformParameters.el, privateTransformParameters.Options);
                        }
                        var el = privateTransformParameters.el;
                        if ((!el.transform.wasChanged) && (el.transform.isAvailable)) {
                            el.transform.isAvailable = false;
                            el.transform.wasChanged = true;
                            el.transform.hCurrent = el.transform.hFrom;
                            el.transform.wCurrent = el.transform.wFrom;
                            el.transform.sw = (el.transform.wTo - el.transform.wFrom) / el.transform.tt;
                            el.transform.sh = (el.transform.hTo - el.transform.hFrom) / el.transform.tt;
                            if (privateTransformParameters.Events.onStart) privateTransformParameters.Events.onStart(this);
                            elem = el;
                            for (var tm = 0; tm < (el.transform.duration); tm += privateTransformParameters.tickTimes) setTimeout(_transformthis, tm);
                            setTimeout(function () {
                                el.transform.isAvailable = true; if (privateTransformParameters.Events.onStop) privateTransformParameters.Events.onStop(this);
                                if (privateTransformParameters.Events.onComplete) privateTransformParameters.Events.onComplete(this);
                            }, el.transform.duration);
                        }
                        else if ((el.transform.wasChanged) && (el.transform.isAvailable)) {
                            el.transform.isAvailable = false;
                            el.transform.wasChanged = false;
                            el.transform.hCurrent = el.transform.hTo;
                            el.transform.wCurrent = el.transform.wTo;
                            el.transform.sw = (el.transform.wFrom - el.transform.wTo) / el.transform.tt;
                            el.transform.sh = (el.transform.hFrom - el.transform.hTo) / el.transform.tt;
                            if (privateTransformParameters.Events.onStart) privateTransformParameters.Events.onStart(this);
                            elem = el;
                            for (var tm = 0; tm < (el.transform.duration); tm += privateTransformParameters.tickTimes) setTimeout(_transformthis, tm);
                            setTimeout(function () {
                                el.transform.isAvailable = true; if (privateTransformParameters.Events.onStop) privateTransformParameters.Events.onStop(this);
                                if (privateTransformParameters.Events.onComplete) privateTransformParameters.Events.onComplete(this);
                            }, el.transform.duration);
                        }
                    } catch (Error) { privateTransformParameters.Events.onError(Error); }
                };
                function _transformIn() {
                    try {
                        if (!privateTransformParameters.isCreated) {
                            privateTransformParameters.isCreated = true;
                            _instantiating(privateTransformParameters.el, privateTransformParameters.Options);
                        }
                        var el = privateTransformParameters.el;
                        if ((!el.transform.wasChanged) && (el.transform.isAvailable)) {
                            el.transform.isAvailable = false;
                            el.transform.wasChanged = true;
                            el.transform.hCurrent = el.transform.hFrom;
                            el.transform.wCurrent = el.transform.wFrom;
                            el.transform.sw = (el.transform.wTo - el.transform.wFrom) / el.transform.tt;
                            el.transform.sh = (el.transform.hTo - el.transform.hFrom) / el.transform.tt;
                            if (privateTransformParameters.Events.onStart) privateTransformParameters.Events.onStart(this);
                            elem = el;
                            for (var tm = 0; tm < (el.transform.duration); tm += privateTransformParameters.tickTimes) setTimeout(_transformthis, tm);
                            setTimeout(function () {
                                el.transform.isAvailable = true; if (privateTransformParameters.Events.onStop) privateTransformParameters.Events.onStop(this);
                                if (privateTransformParameters.Events.onComplete) privateTransformParameters.Events.onComplete(this);
                            }, el.transform.duration);
                        }
                    } catch (Error) { privateTransformParameters.Events.onError(Error); }
                };
                function _transformOut() {
                    try {
                        if (!privateTransformParameters.isCreated) {
                            privateTransformParameters.isCreated = true;
                            _instantiating(privateTransformParameters.el, privateTransformParameters.Options);
                        }
                        var el = privateTransformParameters.el;
                        if ((el.transform.wasChanged) && (el.transform.isAvailable)) {
                            el.transform.isAvailable = false;
                            el.transform.wasChanged = false;
                            el.transform.hCurrent = el.transform.hTo;
                            el.transform.wCurrent = el.transform.wTo;
                            el.transform.sw = (el.transform.wFrom - el.transform.wTo) / el.transform.tt;
                            el.transform.sh = (el.transform.hFrom - el.transform.hTo) / el.transform.tt;
                            if (privateTransformParameters.Events.onStart) privateTransformParameters.Events.onStart(this);
                            elem = el;
                            for (var tm = 0; tm < (el.transform.duration); tm += privateTransformParameters.tickTimes) setTimeout(_transformthis, tm);
                            setTimeout(function () {
                                el.transform.isAvailable = true; if (privateTransformParameters.Events.onStop) privateTransformParameters.Events.onStop(this);
                                if (privateTransformParameters.Events.onComplete) privateTransformParameters.Events.onComplete(this);
                            }, el.transform.duration);
                        }
                    } catch (Error) { privateTransformParameters.Events.onError(Error); }
                }

                _initialize(object, options);
                //Public Members
                this.Toogle = function () {
                    _toogle();
                };
                this.TransformIn = function () {
                    _transformIn();
                };
                this.TransformOut = function () {
                    _transformthis();
                };
            } catch (Error) { privateParameters.Events.onError(Error); }
        };
        // ---------------------------------------------------------------------------- //

        // ---------------------------- CollapseClass --------------------------------- //
        function _CollapseClass(object, options) {
            try {
                var privateCollapseParameters = null;
                var elem = null;
                function _instantiating() {
                    try {
                        var duration = 50; //defaultValue
                        var H1 = -1; var H2 = -1;
                        var W1 = -1; var W2 = -1;
                        var aj; var el = privateCollapseParameters.el;
                        var options = privateCollapseParameters.Options;

                        if ((options) && (options != undefined)) {
                            if (options.duration != undefined) duration = options.duration;
                            if (options.toWidth != undefined) W2 = options.toWidth;
                            if (options.fromWidth != undefined) W1 = options.fromWidth;
                            if (options.toHeight != undefined) H2 = options.toHeight;
                            if (options.fromHeight != undefined) H1 = options.fromHeight;
                        }
                        if (el) {
                            if (el.collapse == undefined) {
                                el.collapse = {};
                                el.collapse.wasChanged = false;
                                el.collapse.isAvailable = true;
                                el.collapse.duration = duration;
                                if ((W1 == -1) && (W2 == -1)) {
                                    W1 = el.clientWidth; if (W1 == 0) W1 = el.offsetWidth;
                                    W2 = el.clientWidth; if (W2 == 0) W2 = el.offsetWidth;
                                }
                                else {
                                    if (W1 == -1) W1 = 0; else {
                                        if (options.fromWidth.indexOf('%') > -1) { el.collapse.wUnit = '%'; W1 = options.fromWidth.replace('%', ''); }
                                        else { el.collapse.wUnit = 'px'; W1 = options.fromWidth.replace('px', ''); }
                                    }
                                    if (W2 == -1) W2 = 0; else {
                                        if (options.toWidth.indexOf('%') > -1) { el.collapse.wUnit = '%'; W2 = options.toWidth.replace('%', ''); }
                                        else { el.collapse.wUnit = 'px'; W2 = options.toWidth.replace('px', ''); }
                                    }
                                }
                                if (H2 == -1) H2 = 0; else {
                                    if (options.toHeight.indexOf('%') > -1) { el.collapse.hUnit = '%'; H2 = options.toHeight.replace('%', ''); }
                                    else { el.collapse.wUnit = 'px'; H2 = options.toHeight.replace('px', ''); }
                                }
                                if (H1 == -1) H1 = el.clientHeight; else {
                                    if (options.fromHeight.indexOf('%') > -1) { el.collapse.hUnit = '%'; H1 = options.fromHeight.replace('%', ''); }
                                    else { el.collapse.hUnit = 'px'; H1 = options.fromHeight.replace('px', ''); }
                                }

                                if (H1 == 0) H1 = el.offsetHeight;

                                if (el.style.height.indexOf('px') > -1) el.collapse.hUnit = 'px';
                                else if (el.style.height.indexOf('%') > -1) el.collapse.hUnit = '%';
                                else { el.collapse.hUnit = 'px'; }
                                if (el.style.width.indexOf('px') > -1) el.collapse.wUnit = 'px';
                                else if (el.style.width.indexOf('%') > -1) el.collapse.wUnit = '%';
                                else { el.collapse.wUnit = 'px'; }
                                if (el.style.height.indexOf('px') > -1) el.collapse.hUnit = 'px';
                                else if (el.style.height.indexOf('%') > -1) el.collapse.hUnit = '%';
                                else { el.collapse.hUnit = 'px'; }
                                el.collapse.hFrom = parseFloat(H1);
                                el.collapse.wFrom = parseFloat(W1);
                                el.collapse.hTo = parseFloat(H2);
                                el.collapse.wTo = parseFloat(W2);
                                el.collapse.hCurrent = parseFloat(H1);
                                el.collapse.wCurrent = parseFloat(W1);

                                var vBorder = 0;
                                if (el.style.borderTopWidth != '') vBorder = parseInt(el.style.borderTopWidth.replace('px', ''));
                                if (el.style.borderBottomWidth != '') vBorder += parseInt(el.style.borderBottomWidth.replace('px', ''));
                                var hBorder = 0;
                                if (el.style.borderLeftWidth != '') hBorder = parseInt(el.style.borderLeftWidth.replace('px', ''));
                                if (el.style.borderRightWidth != '') hBorder += parseInt(el.style.borderRightWidth.replace('px', ''));
                                el.style.position = 'absolute';
                                el.collapse.hBorder = hBorder;
                                el.collapse.vBorder = vBorder;
                                el.collapse.tt = el.collapse.duration / privateCollapseParameters.tickTimes;
                                privateCollapseParameters.isCreated = true;
                            }
                            else if ((privateCollapseParameters.isCreated) && (el != null)) {
                                var duration = 50; //defaultValue
                                var H1 = -1; var H2 = -1;
                                var W1 = -1; var W2 = -1;
                                var aj;

                                if ((options) && (options != undefined)) {
                                    if (options.duration != undefined) duration = options.duration;
                                    if (options.toWidth != undefined) W2 = options.toWidth;
                                    if (options.fromWidth != undefined) W1 = options.fromWidth;
                                    if (options.toHeight != undefined) H2 = options.toHeight;
                                    if (options.fromHeight != undefined) H1 = options.fromHeight;
                                }

                                el.collapse = new Object();
                                el.collapse.wasChanged = false;
                                el.collapse.isAvailable = true;
                                el.collapse.duration = duration;
                                if ((W1 == -1) && (W2 == -1)) {
                                    W1 = el.clientWidth; if (W1 == 0) W1 = el.offsetWidth;
                                    W2 = el.clientWidth; if (W2 == 0) W2 = el.offsetWidth;
                                }
                                else {
                                    if (W1 == -1) W1 = 0; else {
                                        if (options.fromWidth.indexOf('%') > -1) { el.collapse.wUnit = '%'; W1 = options.fromWidth.replace('%', ''); }
                                        else { el.collapse.wUnit = 'px'; W1 = options.fromWidth.replace('px', ''); }
                                    }
                                    if (W2 == -1) W2 = 0; else {
                                        if (options.toWidth.indexOf('%') > -1) { el.collapse.wUnit = '%'; W2 = options.toWidth.replace('%', ''); }
                                        else { el.collapse.wUnit = 'px'; W2 = options.toWidth.replace('px', ''); }
                                    }
                                }
                                if (H2 == -1) H2 = 0; else {
                                    if (options.toHeight.indexOf('%') > -1) { el.collapse.hUnit = '%'; H2 = options.toHeight.replace('%', ''); }
                                    else { el.collapse.wUnit = 'px'; H2 = options.toHeight.replace('px', ''); }
                                }
                                if (H1 == -1) H1 = el.clientHeight; else {
                                    if (options.fromHeight.indexOf('%') > -1) { el.collapse.hUnit = '%'; H1 = options.fromHeight.replace('%', ''); }
                                    else { el.collapse.hUnit = 'px'; H1 = options.fromHeight.replace('px', ''); }
                                }

                                if (H1 == 0) H1 = el.offsetHeight;

                                if (el.style.height.indexOf('px') > -1) el.collapse.hUnit = 'px';
                                else if (el.style.height.indexOf('%') > -1) el.collapse.hUnit = '%';
                                else { el.collapse.hUnit = 'px'; }
                                if (el.style.width.indexOf('px') > -1) el.collapse.wUnit = 'px';
                                else if (el.style.width.indexOf('%') > -1) el.collapse.wUnit = '%';
                                else { el.collapse.wUnit = 'px'; }
                                if (el.style.height.indexOf('px') > -1) el.collapse.hUnit = 'px';
                                else if (el.style.height.indexOf('%') > -1) el.collapse.hUnit = '%';
                                else { el.collapse.hUnit = 'px'; }
                                el.collapse.hFrom = parseFloat(H1);
                                el.collapse.wFrom = parseFloat(W1);
                                el.collapse.hTo = parseFloat(H2);
                                el.collapse.wTo = parseFloat(W2);
                                el.collapse.hCurrent = parseFloat(H1);
                                el.collapse.wCurrent = parseFloat(W1);

                                var vBorder = 0;
                                if (el.style.borderTopWidth != '') vBorder = parseInt(el.style.borderTopWidth.replace('px', ''));
                                if (el.style.borderBottomWidth != '') vBorder += parseInt(el.style.borderBottomWidth.replace('px', ''));

                                var hBorder = 0;
                                if (el.style.borderLeftWidth != '') hBorder = parseInt(el.style.borderLeftWidth.replace('px', ''));
                                if (el.style.borderRightWidth != '') hBorder += parseInt(el.style.borderRightWidth.replace('px', ''));

                                el.style.position = 'absolute';
                                el.collapse.hBorder = hBorder;
                                el.collapse.vBorder = vBorder;
                                el.collapse.tt = el.collapse.duration / privateCollapseParameters.tickTimes;
                                privateCollapseParameters.el = el;
                            }
                        }
                        else return;
                    } catch (Error) { privateCollapseParameters.Events.onError(Error); }
                };
                function _initialize(myDiv, options) {
                    try {
                        privateCollapseParameters = {};
                        privateCollapseParameters.el = myDiv;
                        privateCollapseParameters.Options = options;
                        privateCollapseParameters.isCreated = false;
                        //privateCollapseParameters.fx = options.fx;
                        privateCollapseParameters.Events = (options.events) ? options.events : {};
                        privateCollapseParameters.tickTimes = 10;
                        _instantiating();
                        return this;
                    } catch (Error) { privateCollapseParameters.Events.onError(Error); }
                }
                function _isCollapse() {
                    try {
                        if (!privateCollapseParameters.isCreated) _instantiating();
                        if ((privateCollapseParameters.el) && (privateCollapseParameters.el.collapse))
                            return privateCollapseParameters.el.collapse.wasChanged;
                        else return false;
                    } catch (Error) { privateCollapseParameters.Events.onError(Error); }
                };
                function _collapsethis() {
                    try {
                        if (elem) {
                            elem.collapse.hCurrent += elem.collapse.sh;
                            elem.collapse.wCurrent += elem.collapse.sw;
                            var w = (elem.collapse.wCurrent + elem.collapse.hBorder) + elem.collapse.wUnit;
                            var h = (elem.collapse.hCurrent + elem.collapse.vBorder) + elem.collapse.hUnit;
                            elem.style.clip = 'rect(0px ' + w + ' ' + h + ' 0px)';
                        }
                    } catch (Error) { privateCollapseParameters.Events.onError(Error); }
                };
                function _toogle() {
                    try {
                        var el = privateCollapseParameters.el;
                        if ((el) && (el.collapse)) {
                            if ((!el.collapse.wasChanged) && (el.collapse.isAvailable)) _slideIn();
                            else if ((el.collapse.wasChanged) && (el.collapse.isAvailable)) _slideOut();
                        }
                        else _slideIn();
                    } catch (Error) { privateCollapseParameters.Events.onError(Error); }
                };
                function _slideIn() {
                    try {
                        if (!privateCollapseParameters.isCreated)
                            _instantiating();

                        var el = privateCollapseParameters.el;
                        if ((!el.collapse.wasChanged) && (el.collapse.isAvailable)) {
                            el.collapse.wasChanged = true;
                            el.collapse.isAvailable = false;
                            el.collapse.hCurrent = el.collapse.hFrom;
                            el.collapse.wCurrent = el.collapse.wFrom;
                            el.collapse.sw = (el.collapse.wTo - el.collapse.wFrom) / el.collapse.tt;
                            el.collapse.sh = (el.collapse.hTo - el.collapse.hFrom) / el.collapse.tt;
                            if (privateCollapseParameters.Events.onStart) privateCollapseParameters.Events.onStart(this);
                            elem = el;
                            for (var tm = 0; tm < (el.collapse.duration); tm += privateCollapseParameters.tickTimes) setTimeout(_collapsethis, tm);
                            setTimeout(function () {
                                el.collapse.isAvailable = true; el.style.display = 'none';
                                if (privateCollapseParameters.Events.onStop) privateCollapseParameters.Events.onStop(this);
                                if (privateCollapseParameters.Events.onComplete) privateCollapseParameters.Events.onComplete(this);
                            }, el.collapse.duration);
                        }
                    } catch (Error) { privateCollapseParameters.Events.onError(Error); }
                };
                function _slideOut() {
                    try {
                        if (!privateCollapseParameters.isCreated)
                            _instantiating(privateCollapseParameters.el, privateCollapseParameters.Options);

                        var el = privateCollapseParameters.el;
                        if ((el.collapse.wasChanged) && (el.collapse.isAvailable)) {
                            el.style.display = '';
                            el.collapse.wasChanged = false;
                            el.collapse.isAvailable = false;
                            el.collapse.hCurrent = el.collapse.hTo;
                            el.collapse.wCurrent = el.collapse.wTo;
                            el.collapse.sw = (el.collapse.wFrom - el.collapse.wTo) / el.collapse.tt;
                            el.collapse.sh = (el.collapse.hFrom - el.collapse.hTo) / el.collapse.tt;
                            elem = el;
                            for (var tm = 0; tm < (el.collapse.duration); tm += privateCollapseParameters.tickTimes) setTimeout(_collapsethis, tm);
                            setTimeout(function () {
                                el.collapse.isAvailable = true;
                                if (privateCollapseParameters.Events.onStop) privateCollapseParameters.Events.onStop(this);
                                if (privateCollapseParameters.Events.onComplete) privateCollapseParameters.Events.onComplete(this);
                                var w = (el.collapse.wFrom + el.collapse.hBorder) + el.collapse.wUnit;
                                var h = (el.collapse.hFrom + el.collapse.vBorder) + el.collapse.hUnit;
                                el.style.clip = 'rect(0px ' + w + ' ' + h + ' 0px)';
                            }, el.collapse.duration);
                        }
                    } catch (Error) { privateCollapseParameters.Events.onError(Error); }
                };
                function _objectWasUpdate() {
                    try {
                        var el = privateCollapseParameters.el;
                        if ((el) && (privateCollapseParameters.isCreated)) {
                            var c = el.collapse;
                            if (el.collapse.wasChanged) {//collapse                                
                                if ((c.hTo != el.clientHeight) || (c.wTo != el.clientWidth)) return true;
                                else return false;
                            } else {//not collapse                                
                                if ((c.hFrom != el.clientHeight) || (c.wFrom != el.clientWidth)) return true;
                                else return false;
                            }
                        }
                        return true;
                    } catch (Error) { privateCollapseParameters.Events.onError(Error); }
                };
                _initialize(object, options);

                //Public Members
                this.Toogle = function () {
                    _toogle();
                };
                this.CollapseIn = function () {
                    _slideIn();
                };
                this.CollapseOut = function () {
                    _slideOut();
                };

            } catch (Error) { privateParameters.Events.onError(Error); }
        };
        // ---------------------------------------------------------------------------- //       

        // ---------------------------- OpacityClass ---------------------------------- //
        function _OpacityClass(object, options) {
            try {
                var privateOpacityParameters = null;
                var elem = null;
                function _instantiating() {
                    try {
                        var duration = 150; //defaultValue
                        var from = -1;
                        var to = -1;
                        var aj;
                        var el = privateOpacityParameters.el;
                        var options = privateOpacityParameters.Options;

                        if ((options) && (options != undefined)) {
                            if (options.duration != undefined) duration = options.duration;
                            if (options.from != undefined) from = options.from;
                            if (options.to != undefined) to = options.to;
                        }
                        if (el) {
                            if (el.opacity == undefined) {
                                el.opacity = {};
                                el.opacity.wasChanged = false;
                                el.opacity.isAvailable = true;
                                el.opacity.duration = duration;
                                el.opacity.to = to;
                                el.opacity.from = from;
                                el.opacity.current = from;
                                el.opacity.tt = el.opacity.duration / privateOpacityParameters.tickTimes;
                            }
                        }
                        else return;
                    } catch (Error) { privateOpacityParameters.Events.onError(Error); }
                };
                function _initialize(myDiv, options) {
                    try {
                        privateOpacityParameters = new Object();
                        privateOpacityParameters.el = myDiv;
                        privateOpacityParameters.Options = options;
                        privateOpacityParameters.isCreated = false;
                        //privateOpacityParameters.fx = options.fx;
                        privateOpacityParameters.Events = (options.events) ? options.events : {};
                        privateOpacityParameters.tickTimes = 10;
                        _instantiating();
                        return this;
                    } catch (Error) { privateOpacityParameters.Events.onError(Error); }
                };
                function _opacitythis() {
                    try {
                        if (elem) {
                            elem.opacity.current += elem.opacity.fo;
                            elem.style.opacity = elem.opacity.current;
                            elem.style.filter = 'alpha(opacity=' + elem.opacity.current * 100 + ')';
                        }
                    } catch (Error) { privateOpacityParameters.Events.onError(Error); }
                };
                function _toogle() {
                    try {
                        if (!privateOpacityParameters.isCreated) {
                            privateOpacityParameters.isCreated = true;
                            _instantiating();
                        }
                        var el = privateOpacityParameters.el;
                        if ((!el.opacity.wasChanged) && (el.opacity.isAvailable)) { el.opacity.fo = (el.opacity.to - el.opacity.from) / el.opacity.tt; el.opacity.wasChanged = true; }
                        else if ((el.opacity.wasChanged) && (el.opacity.isAvailable)) { el.opacity.fo = (el.opacity.from - el.opacity.to) / el.opacity.tt; el.opacity.wasChanged = false; }
                        el.opacity.isAvailable = false;
                        if (privateOpacityParameters.Events.onStart) privateOpacityParameters.Events.onStart(this);
                        elem = el;
                        for (var tm = 0; tm < (el.opacity.duration); tm += privateOpacityParameters.tickTimes) setTimeout(_opacitythis, tm);
                        setTimeout(function () {
                            el.opacity.isAvailable = true;
                            if (privateOpacityParameters.Events.onStop) privateOpacityParameters.Events.onStop(this);
                            if (privateOpacityParameters.Events.onComplete) privateOpacityParameters.Events.onComplete(this);
                        }, el.opacity.duration);
                    } catch (Error) { privateOpacityParameters.Events.onError(Error); }
                };
                function _fadeIn() {
                    try {
                        if (!privateOpacityParameters.isCreated) {
                            privateOpacityParameters.isCreated = true;
                            _instantiating();
                        }
                        var el = privateOpacityParameters.el;
                        var fo = (el.opacity.to - el.opacity.from) / el.opacity.tt;
                        el.opacity.fo = fo;
                        el.style.opacity = el.opacity.current;
                        el.style.filter = 'alpha(opacity=' + el.opacity.current * 100 + ')';
                        if ((!el.opacity.wasChanged) && (el.opacity.isAvailable)) {
                            el.opacity.isAvailable = false;
                            el.opacity.wasChanged = true;
                            if (privateOpacityParameters.Events.onStart) privateOpacityParameters.Events.onStart(this);
                            elem = el;
                            for (var tm = 0; tm < (el.opacity.duration); tm += privateOpacityParameters.tickTimes) setTimeout(_opacitythis, tm);
                            setTimeout(function () {
                                el.opacity.isAvailable = true;
                                if (privateOpacityParameters.Events.onStop) privateOpacityParameters.Events.onStop(this);
                                if (privateOpacityParameters.Events.onComplete) privateOpacityParameters.Events.onComplete(this);
                            }, el.opacity.duration);
                        }
                    } catch (Error) { privateOpacityParameters.Events.onError(Error); }
                };
                function _fadeOut() {
                    try {
                        if (!privateOpacityParameters.isCreated) {
                            privateOpacityParameters.isCreated = true;
                            this.instantiating(privateOpacityParameters.el, privateOpacityParameters.Options);
                        }
                        var el = privateOpacityParameters.el;
                        var fo = (el.opacity.from - el.opacity.to) / el.opacity.tt;
                        el.opacity.fo = fo;
                        el.style.opacity = el.opacity.current;
                        el.style.filter = 'alpha(opacity=' + el.opacity.current * 100 + ')';
                        if ((el.opacity.wasChanged) && (el.opacity.isAvailable)) {
                            el.opacity.isAvailable = false;
                            el.opacity.wasChanged = false;
                            if (privateOpacityParameters.Events.onStart) privateOpacityParameters.Events.onStart(this);
                            elem = el;
                            for (var tm = 0; tm < (el.opacity.duration); tm += privateOpacityParameters.tickTimes) setTimeout(_opacitythis, tm);
                            setTimeout(function () {
                                el.opacity.isAvailable = true;
                                if (privateOpacityParameters.Events.onStop) privateOpacityParameters.Events.onStop(this);
                                if (privateOpacityParameters.Events.onComplete) privateOpacityParameters.Events.onComplete(this);
                            }, el.opacity.duration);
                        }
                    } catch (Error) { privateOpacityParameters.Events.onError(Error); }
                };
                _initialize(object, options);

                //Public Members
                this.Toogle = function () {
                    _toogle();
                };
                this.OpacityIn = function () {
                    _fadeIn();
                };
                this.OpacityOut = function () {
                    _fadeOut();
                };
            } catch (Error) { privateParameters.Events.onError(Error); }
        };

        // ---------------------------------------------------------------------------- //

        // ---------------------------- MoveClass ------------------------------------- //
        function _MoveClass(object, options) {
            try {
                var privateMoveParameters = null;
                var elem = null;
                function _instantiating() {
                    try {
                        var duration = 250; //defaultValue
                        var fromX = -1; var toX = -1;
                        var fromY = -1; var toY = -1;
                        var aj;
                        var el = privateMoveParameters.el;
                        var options = privateMoveParameters.Options;

                        if ((options) && (options != undefined)) {
                            if (options.duration != undefined) duration = options.duration;
                            if (options.fromX != undefined) fromX = options.fromX;
                            if (options.fromY != undefined) fromY = options.fromY;
                            if (options.toX != undefined) toX = options.toX;
                            if (options.toY != undefined) toY = options.toY;
                        }
                        if (el) {
                            if (el.move == undefined) {
                                el.move = {};
                                el.move.wasChanged = false;
                                el.move.isAvailable = true;
                                el.move.duration = duration;
                                el.move.xFrom = fromX;
                                el.move.xTo = toX;
                                el.move.yFrom = fromY;
                                el.move.yTo = toY;
                                el.move.xCurrent = fromX;
                                el.move.yCurrent = fromY;

                                el.move.tt = el.move.duration / privateMoveParameters.tickTimes;
                                el.move.sx = (toX - fromX) / el.move.tt;
                                el.move.sy = (toY - fromY) / el.move.tt;

                                if (el.style.position == 'absolute') {
                                    if (el.style.left.indexOf('px') > -1) el.move.xUnit = 'px'
                                    else if (el.style.left.indexOf('%') > -1) el.move.xUnit = '%'
                                    else { el.style.left = '0px'; el.move.xUnit = 'px'; }
                                    if (el.style.top.indexOf('px') > -1) el.move.yUnit = 'px'
                                    else if (el.style.top.indexOf('%') > -1) el.move.yUnit = '%'
                                    else { el.style.top = '0px'; el.move.yUnit = 'px'; }
                                } else {
                                    if (el.style.marginLeft.idnexOf('px') > -1) el.move.xUnit = 'px'
                                    else if (el.style.marginLeft.indexOf('%') > -1) el.move.xUnit = '%'
                                    else { el.style.marginLeft = '0px'; el.move.xUnit = 'px'; }
                                    if (el.style.marginTop.indexOf('px') > -1) el.move.yUnit = 'px'
                                    else if (el.style.marginTop.indexOf('%') > -1) el.move.yUnit = '%'
                                    else { el.style.marginTop = '0px'; el.move.yUnit = 'px'; }
                                }
                                privateMoveParameters.isCreated = true;
                            }
                        }
                        else return;
                    } catch (Error) { privateMoveParameters.Events.onError(Error); }
                };
                function _initialize(myDiv, options) {
                    try {
                        privateMoveParameters = {};
                        privateMoveParameters.el = myDiv;
                        privateMoveParameters.Options = options;
                        privateMoveParameters.isCreated = false;
                        privateMoveParameters.Events = (options.events) ? options.events : {};
                        privateMoveParameters.tickTimes = 10;
                        _instantiating();
                        return this;
                    } catch (Error) { privateMoveParameters.Events.onError(Error); }
                };
                function _movethis() {
                    try {
                        if (elem) {
                            if (elem.style.position == 'absolute') {
                                elem.move.xCurrent += elem.move.sx;
                                elem.move.yCurrent += elem.move.sy;
                                elem.style.left = elem.move.xCurrent + elem.move.xUnit;
                                elem.style.top = elem.move.yCurrent + elem.move.yUnit;
                            }
                            else {
                                elem.move.xCurrent += elem.move.sx;
                                elem.move.yCurrent += elem.move.sy;
                                elem.style.marginLeft = elem.move.xCurrent + elem.move.xUnit;
                                elem.style.marginTop = elem.move.yCurrent + elem.move.yUnit;
                            }
                        }
                    } catch (Error) { privateMoveParameters.Events.onError(Error); }
                };
                function _move() {
                    try {
                        if (!privateMoveParameters.isCreated) {
                            privateMoveParameters.isCreated = true;
                            _instantiating();
                        }
                        var el = privateMoveParameters.el;
                        if (el.move.isAvailable) {
                            el.move.isAvailable = false;
                            el.move.xCurrent = el.move.xFrom;
                            el.move.yCurrent = el.move.yFrom;
                            if (privateMoveParameters.Events.onStart) privateMoveParameters.Events.onStart(this);
                            elem = el;
                            for (var tm = 0; tm < (el.move.duration); tm += privateMoveParameters.tickTimes) setTimeout(_movethis, tm);
                            setTimeout(function () {
                                el.move.isAvailable = true;
                                if (privateMoveParameters.Events.onStop) privateMoveParameters.Events.onStop(this);
                                if (privateMoveParameters.Events.onComplete) privateMoveParameters.Events.onComplete(this);
                            }, el.move.duration);
                        }
                    } catch (Error) { privateMoveParameters.Events.onError(Error); }
                };
                function _toogle() {
                    try {
                        if (!privateMoveParameters.isCreated) {
                            privateMoveParameters.isCreated = true;
                            _instantiating();
                        }
                        var el = privateMoveParameters.el;
                        if (el.move.wasChanged) _moveOut();
                        else _moveIn();
                    } catch (Error) { privateMoveParameters.Events.onError(Error); }
                };
                function _moveIn() {
                    try {
                        if (!privateMoveParameters.isCreated) {
                            privateMoveParameters.isCreated = true;
                            _instantiating();
                        }
                        var el = privateMoveParameters.el;
                        if (el.move.isAvailable) {
                            el.move.isAvailable = false;
                            el.move.wasChanged = true;
                            el.move.xCurrent = el.move.xFrom;
                            el.move.yCurrent = el.move.yFrom;
                            el.move.sx = (el.move.xTo - el.move.xFrom) / el.move.tt;
                            el.move.sy = (el.move.yTo - el.move.yFrom) / el.move.tt;
                            if (privateMoveParameters.Events.onStart) privateMoveParameters.Events.onStart(this); elem = el;
                            for (var tm = 0; tm < (el.move.duration); tm += privateMoveParameters.tickTimes) setTimeout(_movethis, tm);
                            setTimeout(function () {
                                el.move.isAvailable = true;
                                if (privateMoveParameters.Events.onStop) privateMoveParameters.Events.onStop(this);
                                if (privateMoveParameters.Events.onComplete) privateMoveParameters.Events.onComplete(this);
                            }, el.move.duration);
                        }
                    } catch (Error) { privateMoveParameters.Events.onError(Error); }
                };
                function _moveOut() {
                    try {
                        if (!privateMoveParameters.isCreated) {
                            privateMoveParameters.isCreated = true;
                            _instantiating();
                        }
                        var el = privateMoveParameters.el;
                        if (el.move.isAvailable) {
                            el.move.isAvailable = false;
                            el.move.wasChanged = false;
                            el.move.xCurrent = el.move.xTo;
                            el.move.yCurrent = el.move.yTo;
                            el.move.sx = (el.move.xFrom - el.move.xTo) / el.move.tt;
                            el.move.sy = (el.move.yFrom - el.move.yTo) / el.move.tt;
                            if (privateMoveParameters.Events.onStart) privateMoveParameters.Events.onStart(this); elem = el;
                            for (var tm = 0; tm < (el.move.duration); tm += privateMoveParameters.tickTimes) setTimeout(_movethis, tm);
                            setTimeout(function () {
                                el.move.isAvailable = true;
                                if (privateMoveParameters.Events.onStop) privateMoveParameters.Events.onStop(this);
                                if (privateMoveParameters.Events.onComplete) privateMoveParameters.Events.onComplete(this);
                            }, el.move.duration);
                        }
                    } catch (Error) { privateMoveParameters.Events.onError(Error); }
                };

                _initialize(object, options);
                //Public Members
                this.Toogle = function () {
                    _toogle();
                };
                this.MoveIn = function () {
                    _moveIn();
                };
                this.MoveOut = function () {
                    _moveOut();
                };
            } catch (Error) { privateParameters.Events.onError(Error); }
        }

        // ---------------------------------------------------------------------------- //

        //Public Members
        this.Shadow = function (object, options) {
            this.Shadow = new _ShadowClass(object, options);
        };
        this.Transform = function (object, options) {
            this.Transform = new _TransformClass(object, options);
        };
        this.Move = function (object, options) {
            this.Move = new _MoveClass(object, options);
        };
        this.Opacity = function (object, options) {
            this.Opacity = new _OpacityClass(object, options);
        };
        this.Collapse = function (object, options) {
            this.Collapse = new _CollapseClass(object, options);
        };
        this.Drag = function (object, options) {
            this.Drag = new _DragClass(object, options);
        };
    }
    window.FX = function () { return new _FX(); }
})();
/* ////////////////////////////////////////////////////////////////////////////////////////////////// */
